﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Imagin.Controls.Common">
    <Style TargetType="{x:Type local:ButtonChrome}">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ButtonChrome}">
                    <Grid>
                        <Border 
                            x:Name="OuterBorder" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            CornerRadius="{TemplateBinding CornerRadius}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            Background="{TemplateBinding Background}">
                            <Border 
                                x:Name="InnerBorder" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                CornerRadius="{TemplateBinding InnerCornerRadius}"/>
                            <!-- BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonNormalInnerBorderKey}}" -->
                        </Border>
                        <Border 
                            x:Name="MouseOverVisual" 
                            Opacity="0" 
                            Visibility="Collapsed" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            CornerRadius="{TemplateBinding CornerRadius}">
                            <!--
                            BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonMouseOverOuterBorderKey}}" 
                            Background="{DynamicResource {x:Static themes:ResourceKeys.ButtonMouseOverBackgroundKey}}"
                            -->
                            <Border 
                                x:Name="MouseOverInnerVisual" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                CornerRadius="{TemplateBinding InnerCornerRadius}"/>
                            <!-- BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonMouseOverInnerBorderKey}}"-->
                        </Border>
                        <Border 
                            x:Name="PressedVisual" 
                            Opacity="0" 
                            Visibility="Collapsed" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            CornerRadius="{TemplateBinding CornerRadius}">
                            <!--
                            BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedOuterBorderKey}}" 
                            Background="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedBackgroundKey}}">
                            -->
                            <Border
                                x:Name="PressedInnerVisual" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                CornerRadius="{TemplateBinding InnerCornerRadius}"/>
                            <!--
                                BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedInnerBorderKey}}"
                                -->
                        </Border>
                        <Border 
                            x:Name="FocusVisual" 
                            Opacity="0" 
                            Visibility="Collapsed" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            CornerRadius="{TemplateBinding CornerRadius}">
                            <!--
                            BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonFocusedOuterBorderKey}}"
                            Background="{DynamicResource {x:Static themes:ResourceKeys.ButtonFocusedBackgroundKey}}">
                            -->
                            <Border 
                                x:Name="FocusInnerVisual" 
                                BorderThickness="1" 
                                CornerRadius="{TemplateBinding InnerCornerRadius}"/>
                            <!-- BorderBrush="{DynamicResource {x:Static themes:ResourceKeys.ButtonFocusedInnerBorderKey}}" -->
                        </Border>
                        <ContentPresenter 
                            Margin="{TemplateBinding Padding}"
							IsEnabled="{TemplateBinding IsEnabled}"
							Content="{TemplateBinding Content}"
							ContentStringFormat="{TemplateBinding ContentStringFormat}"
							ContentTemplate="{TemplateBinding ContentTemplate}"
							ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <!-- If button is disabled, not checked, and is rendered normal -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderEnabled" Value="False" />
                                <Condition Property="RenderChecked" Value="False" />
                            </MultiTrigger.Conditions>
                            <!--
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonDisabledOuterBorderKey}}" />
                            <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonInnerBorderDisabledKey}}" />
                            <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource {x:Static themes:ResourceKeys.ControlDisabledBackgroundKey}}" />
                            -->
                        </MultiTrigger>
                        <!-- if button is enabled and pressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderEnabled" Value="True" />
                                <Condition Property="RenderPressed" Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.050" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00.115">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PressedVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.115" Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <!-- if button is enabled, is not checked, the mouse is over, and not pressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderEnabled" Value="True" />
                                <Condition Property="RenderChecked" Value="False" />
                                <Condition Property="RenderMouseOver" Value="True" />
                                <Condition Property="RenderPressed" Value="False" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.115" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00.150">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MouseOverVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.150" Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <!-- if button is enabled, checked, he mouse is not over, and it is not pressed -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderEnabled" Value="True" />
                                <Condition Property="RenderChecked" Value="True" />
                                <Condition Property="RenderMouseOver" Value="False" />
                                <Condition Property="RenderPressed" Value="False" />
                            </MultiTrigger.Conditions>
                            <!--
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedOuterBorderKey}}" />
                            <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedInnerBorderKey}}" />
                            <Setter TargetName="OuterBorder" Property="Background" Value="{DynamicResource {x:Static themes:ResourceKeys.ButtonPressedBackgroundKey}}" />
                            -->
                        </MultiTrigger>
                        <!-- if button is focused, is enabled, not pressed, and the mouse is not over -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderFocused" Value="True" />
                                <Condition Property="RenderEnabled" Value="True" />
                                <Condition Property="RenderPressed" Value="False" />
                                <Condition Property="RenderMouseOver" Value="False" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.25" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00.115">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.115" Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                        <!-- if not rendered normally -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="RenderNormal" Value="False" />
                                <Condition Property="RenderChecked" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="OuterBorder" Property="BorderBrush" Value="Transparent" />
                            <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{x:Null}" />
                            <Setter TargetName="OuterBorder" Property="Background" Value="Transparent" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>